<!-- redVue.vue -->
<template>
  <div id="red">
    <h2>数据：{{$store.state.count}}</h2>
    <button @click="red">同步减少</button>
    <button @click="redAsync">异步2秒后减少</button>
  </div>
</template>

<script setup>
import { useStore } from "vuex";
const store = useStore();

function red() {
  store.dispatch("redAction");
}

function redAsync() {
  store.dispatch("redAsync", 2000);
}
</script>

<style scoped>
#red {
  background-color: aquamarine;
}
</style>